#include <iostream>
#include <vector>
#include <map>
#include <string>

class GitSubmoduleHelper {
public:
    void analyzeWxWidgets() {
        std::cout << "🔍 wxWidgets Submodule Analysis" << std::endl;
        std::cout << "================================" << std::endl;
        
        std::vector<std::pair<std::string, std::string>> submodules = {
            {"3rdparty/catch", "Catch2 testing framework"},
            {"3rdparty/libwebp", "WebP image format support"},
            {"3rdparty/nanosvg", "SVG parsing library"},
            {"3rdparty/pcre", "Perl Compatible Regular Expressions"},
            {"src/expat", "XML parsing library"},
            {"src/jpeg", "JPEG image codec (libjpeg-turbo)"},
            {"src/png", "PNG image library"},
            {"src/stc/lexilla", "Lexer infrastructure for Scintilla"},
            {"src/stc/scintilla", "Source code editing component"},
            {"src/tiff", "TIFF image library"},
            {"src/zlib", "Compression library"}
        };
        
        for (const auto& [path, desc] : submodules) {
            std::cout << "📍 " << path << std::endl;
            std::cout << "   " << desc << std::endl;
        }
    }
    
    void setupMirrors() {
        std::cout << "\n🔧 Git Mirror Setup Commands" << std::endl;
        std::cout << "============================" << std::endl;
        
        std::map<std::string, std::string> mirror_config = {
            {"https://github.com/wxWidgets/libexpat.git", "https://gitee.com/mirrors/libexpat"},
            {"https://github.com/wxWidgets/libpng.git", "https://gitee.com/mirrors/libpng"},
            {"https://github.com/wxWidgets/zlib.git", "https://gitee.com/mirrors/zlib"},
            {"https://github.com/wxWidgets/libtiff.git", "https://gitee.com/mirrors/libtiff"},
            {"https://github.com/wxWidgets/libjpeg-turbo.git", "https://gitee.com/mirrors/libjpeg-turbo"},
            {"https://github.com/wxWidgets/Catch.git", "https://gitee.com/mirrors/Catch"},
            {"https://github.com/wxWidgets/libwebp.git", "https://gitee.com/mirrors/libwebp"},
            {"https://github.com/wxWidgets/nanosvg.git", "https://gitee.com/mirrors/nanosvg"},
            {"https://github.com/wxWidgets/pcre.git", "https://gitee.com/mirrors/pcre"},
            {"https://github.com/wxWidgets/lexilla.git", "https://gitee.com/mirrors/lexilla"},
            {"https://github.com/wxWidgets/scintilla.git", "https://gitee.com/mirrors/scintilla"}
        };
        
        for (const auto& [original, mirror] : mirror_config) {
            std::cout << "git config --global url." << mirror << ".insteadof " << original << std::endl;
        }
        
        std::cout << "\n💡 Run these commands to configure Git mirrors" << std::endl;
    }
    
    void downloadGuide() {
        std::cout << "\n🚀 Download Instructions" << std::endl;
        std::cout << "======================" << std::endl;
        
        std::cout << "1. First configure mirrors (run commands above)" << std::endl;
        std::cout << "2. Then run in wxWidgets directory:" << std::endl;
        std::cout << std::endl;
        std::cout << "   cd /d/vc/wxWidgets" << std::endl;
        std::cout << "   git submodule update --init --recursive --progress" << std::endl;
        std::cout << std::endl;
        std::cout << "3. If some submodules fail, download individually:" << std::endl;
        std::cout << "   git submodule update --init src/expat" << std::endl;
        std::cout << "   git submodule update --init src/png" << std::endl;
        std::cout << "   git submodule update --init src/zlib" << std::endl;
    }
    
    void checkCurrentStatus() {
        std::cout << "\n📊 Current Status Check" << std::endl;
        std::cout << "======================" << std::endl;
        std::cout << "Run these commands to check current status:" << std::endl;
        std::cout << std::endl;
        std::cout << "cd /d/vc/wxWidgets" << std::endl;
        std::cout << "git submodule status" << std::endl;
        std::cout << "git config --global --get-regexp url.*.insteadof" << std::endl;
    }
};

int main() {
    GitSubmoduleHelper helper;
    
    std::cout << "=== Universal Node Manager - Git Submodule Helper ===" << std::endl;
    std::cout << std::endl;
    
    helper.analyzeWxWidgets();
    helper.setupMirrors();
    helper.downloadGuide();
    helper.checkCurrentStatus();
    
    std::cout << "\n==================================================" << std::endl;
    std::cout << "🎯 Ready to manage wxWidgets submodules!" << std::endl;
    std::cout << "💡 Copy and run the Git commands above" << std::endl;
    
    return 0;
}
